package com.adtech.farmProducts.adapter;

import android.view.View;
import android.widget.TextView;

import com.adtech.common.widgets.recycler.RecyclerViewAdapter;
import com.adtech.farmProducts.R;
import com.adtech.farmProducts.model.SourceInfo;


/**
 * Author:  xiaocz.
 * Descr:  录入历史
 */
public class InsertListAdapter extends RecyclerViewAdapter<SourceInfo> {

    public InsertListAdapter(AdapterListener<SourceInfo> adapterListener) {
        super(adapterListener);
    }

    @Override
    protected int getItemViewType(int position, SourceInfo data) {
        return R.layout.item_insert_list;
    }

    @Override
    protected ViewHolder<SourceInfo> getViewHolder(View view, int viewType) {
        return new InfoTypeViewHolder(view);
    }

    private static class InfoTypeViewHolder extends ViewHolder<SourceInfo> {

        private TextView tvCode, tvName, tvTime;

        public InfoTypeViewHolder(View itemView) {
            super(itemView);
            tvCode = itemView.findViewById(R.id.tv_code);
            tvName = itemView.findViewById(R.id.tv_name);
            tvTime = itemView.findViewById(R.id.tv_time);
        }

        @Override
        protected void onBind(SourceInfo data, int position) {
            tvCode.setText(data.getSourceCode());
            tvName.setText(data.getProductName());
            tvTime.setText(data.getHandleTime());
        }

        @Override
        public boolean isNeedClick() {
            return true;
        }
    }
}